/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    'us-west-1' = 'tag.us-east-1.aliyuncs.com',
    'cn-hangzhou-finance' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-shanghai-finance-1' = 'tag.aliyuncs.com',
    'ap-northeast-2-pop' = 'tag.aliyuncs.com',
    'cn-beijing-finance-pop' = 'tag.aliyuncs.com',
    'cn-beijing-gov-1' = 'tag.aliyuncs.com',
    'cn-beijing-nu16-b01' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-edge-1' = 'tag.aliyuncs.com',
    'cn-fujian' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-haidian-cm12-c01' = 'tag.cn-north-2-gov-1.aliyuncs.com',
    'cn-hangzhou-bj-b01' = 'tag.aliyuncs.com',
    'cn-hangzhou-internal-prod-1' = 'tag.aliyuncs.com',
    'cn-hangzhou-internal-test-1' = 'tag.aliyuncs.com',
    'cn-hangzhou-internal-test-2' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-hangzhou-internal-test-3' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-hangzhou-test-306' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-hongkong-finance-pop' = 'tag.aliyuncs.com',
    'cn-huhehaote-nebula-1' = 'tag.cn-qingdao-nebula.aliyuncs.com',
    'cn-shanghai-et15-b01' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-shanghai-et2-b01' = 'tag.aliyuncs.com',
    'cn-shanghai-inner' = 'tag.aliyuncs.com',
    'cn-shanghai-internal-test-1' = 'tag.aliyuncs.com',
    'cn-shenzhen-inner' = 'tag.aliyuncs.com',
    'cn-shenzhen-st4-d01' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-shenzhen-su18-b01' = 'tag.aliyuncs.com',
    'cn-wuhan' = 'tag.aliyuncs.com',
    'cn-yushanfang' = 'tag.aliyuncs.com',
    'cn-zhangbei' = 'tag.aliyuncs.com',
    'cn-zhangbei-na61-b01' = 'tag.cn-hangzhou.aliyuncs.com',
    'cn-zhangjiakou-na62-a01' = 'tag.aliyuncs.com',
    'cn-zhengzhou-nebula-1' = 'tag.cn-qingdao-nebula.aliyuncs.com',
    'eu-west-1-oxs' = 'tag.cn-shenzhen-cloudstone.aliyuncs.com',
    'rus-west-1-pop' = 'tag.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('tag', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AttachPolicyRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-de62a0bf400e4b69****'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  targetId?: string(name='TargetId', description='The ID of the object.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required.', example='151266687691****'),
  targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required. The value of this parameter is not case-sensitive.', example='ACCOUNT'),
}

model AttachPolicyResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='4A32F5B0-0B0B-5537-B4A0-7A6E1C3AA96A'),
}

model AttachPolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AttachPolicyResponseBody(name='body'),
}

/**
 * @summary 绑定策略
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to attach a tag policy to the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to attach a tag policy to the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to attach the tag policy with an ID of `p-de62a0bf400e4b69****` to the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request AttachPolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AttachPolicyResponse
 */
async function attachPolicyWithOptions(request: AttachPolicyRequest, runtime: Util.RuntimeOptions): AttachPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AttachPolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 绑定策略
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to attach a tag policy to the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to attach a tag policy to the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to attach the tag policy with an ID of `p-de62a0bf400e4b69****` to the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request AttachPolicyRequest
 * @return AttachPolicyResponse
 */
async function attachPolicy(request: AttachPolicyRequest): AttachPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return attachPolicyWithOptions(request, runtime);
}

model CheckCreatedByEnabledRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
}

model CheckCreatedByEnabledResponseBody = {
  openStatus?: boolean(name='OpenStatus', example='false'),
  requestId?: string(name='RequestId', example='682DD9E1-F530-5D14-A839-A6787FA82B74'),
}

model CheckCreatedByEnabledResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckCreatedByEnabledResponseBody(name='body'),
}

/**
 * @summary 校验CreatedBy开通状态
 *
 * @param request CheckCreatedByEnabledRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckCreatedByEnabledResponse
 */
async function checkCreatedByEnabledWithOptions(request: CheckCreatedByEnabledRequest, runtime: Util.RuntimeOptions): CheckCreatedByEnabledResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CheckCreatedByEnabled',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 校验CreatedBy开通状态
 *
 * @param request CheckCreatedByEnabledRequest
 * @return CheckCreatedByEnabledResponse
 */
async function checkCreatedByEnabled(request: CheckCreatedByEnabledRequest): CheckCreatedByEnabledResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkCreatedByEnabledWithOptions(request, runtime);
}

model CloseCreatedByRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='This parameter is required.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
}

model CloseCreatedByResponseBody = {
  requestId?: string(name='RequestId', example='AECFE0F2-CEC3-5D16-BE4C-E2F95083D063'),
}

model CloseCreatedByResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CloseCreatedByResponseBody(name='body'),
}

/**
 * @summary 关闭CreatedBy服务
 *
 * @param request CloseCreatedByRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CloseCreatedByResponse
 */
async function closeCreatedByWithOptions(request: CloseCreatedByRequest, runtime: Util.RuntimeOptions): CloseCreatedByResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CloseCreatedBy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 关闭CreatedBy服务
 *
 * @param request CloseCreatedByRequest
 * @return CloseCreatedByResponse
 */
async function closeCreatedBy(request: CloseCreatedByRequest): CloseCreatedByResponse {
  var runtime = new Util.RuntimeOptions{};
  return closeCreatedByWithOptions(request, runtime);
}

model CreateAssociatedResourceRulesRequest {
  createRulesList?: [ 
    {
      settingName?: string(name='SettingName', description='This parameter is required.', example='rule:AttachEni-DetachEni-TagInstance:Ecs-Instance:Ecs-Eni'),
      status?: string(name='Status', description='This parameter is required.', example='Enable'),
      tagKeys?: [ string ](name='TagKeys'),
    }
  ](name='CreateRulesList'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
}

model CreateAssociatedResourceRulesResponseBody = {
  requestId?: string(name='RequestId', example='33BD6957-D7B0-500C-ADA1-300414EDCE89'),
}

model CreateAssociatedResourceRulesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateAssociatedResourceRulesResponseBody(name='body'),
}

/**
 * @summary 创建关联资源打TAG规则
 *
 * @param request CreateAssociatedResourceRulesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateAssociatedResourceRulesResponse
 */
async function createAssociatedResourceRulesWithOptions(request: CreateAssociatedResourceRulesRequest, runtime: Util.RuntimeOptions): CreateAssociatedResourceRulesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.createRulesList)) {
    query['CreateRulesList'] = request.createRulesList;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAssociatedResourceRules',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建关联资源打TAG规则
 *
 * @param request CreateAssociatedResourceRulesRequest
 * @return CreateAssociatedResourceRulesResponse
 */
async function createAssociatedResourceRules(request: CreateAssociatedResourceRulesRequest): CreateAssociatedResourceRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAssociatedResourceRulesWithOptions(request, runtime);
}

model CreatePolicyRequest {
  dryRun?: boolean(name='DryRun', description='Specifies whether to perform only a dry run, without performing the actual request. Valid values:

*   false (default): performs a dry run and performs the actual request.
*   true: performs only a dry run.', example='false'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyContent?: string(name='PolicyContent', description='The document of the tag policy.

For more information about the syntax of a tag policy, see [Syntax of a tag policy](https://help.aliyun.com/document_detail/417436.html).

This parameter is required.', example='{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}'),
  policyDesc?: string(name='PolicyDesc', description='The description of the tag policy.

The description must be 0 to 512 characters in length.', example='This is a tag policy example.'),
  policyName?: string(name='PolicyName', description='The name of the tag policy.

The name must be 1 to 128 characters in length and can contain letters, digits, and underscores (_).

This parameter is required.', example='test'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode. Set the value to USER if you use an Alibaba Cloud account or a member of a resource directory to call this API operation to create a tag policy for the Alibaba Cloud account or member.
*   RD: multi-account mode. Set the value to RD if you use the management account of a resource directory to call this API operation to create a tag policy for the resource directory.

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).', example='RD'),
}

model CreatePolicyResponseBody = {
  policyId?: string(name='PolicyId', description='The ID of the tag policy.', example='p-5732750813924f90****'),
  policyName?: string(name='PolicyName', description='The name of the tag policy.', example='test'),
  requestId?: string(name='RequestId', description='The request ID.', example='FDBE270D-C491-5EEC-A5CD-98245422D3F7'),
}

model CreatePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreatePolicyResponseBody(name='body'),
}

/**
 * @summary Creates a tag policy.
 *
 * @description ###
 * This topic provides an example on how to call the API operation to create a tag policy named `test`. In this example, the Tag Policy feature in multi-account mode is used. The tag policy defines that resources to which the `CostCenter:Beijing` or `CostCenter:Shanghai` tag is added are compliant and other resources are not compliant.
 *
 * @param request CreatePolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreatePolicyResponse
 */
async function createPolicyWithOptions(request: CreatePolicyRequest, runtime: Util.RuntimeOptions): CreatePolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dryRun)) {
    query['DryRun'] = request.dryRun;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyContent)) {
    query['PolicyContent'] = request.policyContent;
  }
  if (!Util.isUnset(request.policyDesc)) {
    query['PolicyDesc'] = request.policyDesc;
  }
  if (!Util.isUnset(request.policyName)) {
    query['PolicyName'] = request.policyName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreatePolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates a tag policy.
 *
 * @description ###
 * This topic provides an example on how to call the API operation to create a tag policy named `test`. In this example, the Tag Policy feature in multi-account mode is used. The tag policy defines that resources to which the `CostCenter:Beijing` or `CostCenter:Shanghai` tag is added are compliant and other resources are not compliant.
 *
 * @param request CreatePolicyRequest
 * @return CreatePolicyResponse
 */
async function createPolicy(request: CreatePolicyRequest): CreatePolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return createPolicyWithOptions(request, runtime);
}

model CreateTagsRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID.

> Only `cn-hangzhou` is supported.

This parameter is required.', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tagKeyValueParamList?: [ 
    {
      description?: string(name='Description', description='The description of the key for tag N.

Valid values of N: 1 to 10.', example='Business environment'),
      key?: string(name='Key', description='The value of tag N.

The tag value can be up to 128 characters in length and cannot start with `acs:` or `aliyun`. The tag key cannot contain `http://` or `https://`.

Valid values of N: 1 to 10.

This parameter is required.', example='Environment'),
      tagValueParamList?: [ 
        {
          description?: string(name='Description', description='The description of the value for tag N.

Valid values of N: 1 to 10.', example='Test environment'),
          value?: string(name='Value', description='The value of tag N.

The tag value can be up to 128 characters in length and cannot contain `http://` or `https://`.

Valid values of N: 1 to 10.', example='test'),
        }
      ](name='TagValueParamList', description='The information about the tag values.'),
    }
  ](name='TagKeyValueParamList', description='The information about the tags.

This parameter is required.'),
}

model CreateTagsResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='94E16BB6-3FB6-1297-B5B2-ED2250F437CD'),
}

model CreateTagsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTagsResponseBody(name='body'),
}

/**
 * @summary Creates predefined tags.
 *
 * @description ###
 * A preset tag is a tag that you create in advance and is available for the resources in all regions. You can create preset tags in the stage of tag planning and add them to specific resources in the stage of tag implementation. When you create a preset tag, you can specify only the tag key. You can specify a tag value in the future.
 * This topic provides an example on how to call the API operation to create a preset tag whose tag key is `Environment` to indicate the business environment.
 *
 * @param request CreateTagsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTagsResponse
 */
async function createTagsWithOptions(request: CreateTagsRequest, runtime: Util.RuntimeOptions): CreateTagsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tagKeyValueParamList)) {
    query['TagKeyValueParamList'] = request.tagKeyValueParamList;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateTags',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates predefined tags.
 *
 * @description ###
 * A preset tag is a tag that you create in advance and is available for the resources in all regions. You can create preset tags in the stage of tag planning and add them to specific resources in the stage of tag implementation. When you create a preset tag, you can specify only the tag key. You can specify a tag value in the future.
 * This topic provides an example on how to call the API operation to create a preset tag whose tag key is `Environment` to indicate the business environment.
 *
 * @param request CreateTagsRequest
 * @return CreateTagsResponse
 */
async function createTags(request: CreateTagsRequest): CreateTagsResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTagsWithOptions(request, runtime);
}

model DeleteAssociatedResourceRuleRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  settingName?: string(name='SettingName', example='rule:AttachEni-DetachEni-TagInstance:Ecs-Instance:Ecs-Eni'),
}

model DeleteAssociatedResourceRuleResponseBody = {
  requestId?: string(name='RequestId', example='BB532282-94F5-5F56-877F-32D5E2A04F3F'),
}

model DeleteAssociatedResourceRuleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteAssociatedResourceRuleResponseBody(name='body'),
}

/**
 * @summary 删除关联资源打TAG规则
 *
 * @param request DeleteAssociatedResourceRuleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteAssociatedResourceRuleResponse
 */
async function deleteAssociatedResourceRuleWithOptions(request: DeleteAssociatedResourceRuleRequest, runtime: Util.RuntimeOptions): DeleteAssociatedResourceRuleResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.settingName)) {
    query['SettingName'] = request.settingName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteAssociatedResourceRule',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 删除关联资源打TAG规则
 *
 * @param request DeleteAssociatedResourceRuleRequest
 * @return DeleteAssociatedResourceRuleResponse
 */
async function deleteAssociatedResourceRule(request: DeleteAssociatedResourceRuleRequest): DeleteAssociatedResourceRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteAssociatedResourceRuleWithOptions(request, runtime);
}

model DeletePolicyRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-557cb141331f41c7****'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
}

model DeletePolicyResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='4A32F5B0-0B0B-5537-B4A0-7A6E1C3AA96A'),
}

model DeletePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeletePolicyResponseBody(name='body'),
}

/**
 * @summary 删除策略
 *
 * @description Before you delete a tag policy, make sure that the tag policy is detached from all objects to which the tag policy is attached. For more information about how to detach a tag policy, see [DetachPolicy](https://help.aliyun.com/document_detail/429724.html).
 * This topic provides an example on how to call the API operation to delete the tag policy with an ID of `p-557cb141331f41c7****`.
 *
 * @param request DeletePolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeletePolicyResponse
 */
async function deletePolicyWithOptions(request: DeletePolicyRequest, runtime: Util.RuntimeOptions): DeletePolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeletePolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 删除策略
 *
 * @description Before you delete a tag policy, make sure that the tag policy is detached from all objects to which the tag policy is attached. For more information about how to detach a tag policy, see [DetachPolicy](https://help.aliyun.com/document_detail/429724.html).
 * This topic provides an example on how to call the API operation to delete the tag policy with an ID of `p-557cb141331f41c7****`.
 *
 * @param request DeletePolicyRequest
 * @return DeletePolicyResponse
 */
async function deletePolicy(request: DeletePolicyRequest): DeletePolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return deletePolicyWithOptions(request, runtime);
}

model DeleteTagRequest {
  key?: string(name='Key', description='The tag key.

If no tag value is associated with a tag key, you can specify the `Key` parameter without specifying the Value parameter to delete the tag key. Otherwise, you must specify both the `Key` and `Value` parameters to delete a preset tag.

This parameter is required.', example='Environment'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID.

>  Only `cn-hangzhou` is supported.

This parameter is required.', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  value?: string(name='Value', description='The tag value.', example='test'),
}

model DeleteTagResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='6E27F22C-EDA3-132E-A53F-77DE3BC2343D'),
}

model DeleteTagResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteTagResponseBody(name='body'),
}

/**
 * @summary Deletes a preset tag.
 *
 * @description This topic provides an example on how to call the API operation to delete the preset tag whose tag key is `Environment` and tag value is `test`.
 *
 * @param request DeleteTagRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteTagResponse
 */
async function deleteTagWithOptions(request: DeleteTagRequest, runtime: Util.RuntimeOptions): DeleteTagResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.key)) {
    query['Key'] = request.key;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.value)) {
    query['Value'] = request.value;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteTag',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes a preset tag.
 *
 * @description This topic provides an example on how to call the API operation to delete the preset tag whose tag key is `Environment` and tag value is `test`.
 *
 * @param request DeleteTagRequest
 * @return DeleteTagResponse
 */
async function deleteTag(request: DeleteTagRequest): DeleteTagResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteTagWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage', description='The supported natural language. Valid values:

*   zh-CN: Chinese (default value)
*   en-US: English
*   ja: Japanese', example='zh-CN'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The ID of the region.', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
}

model DescribeRegionsResponseBody = {
  regions?: {
    region?: [ 
    {
      localName?: string(name='LocalName', description='The name of the region.', example='China (Hangzhou)'),
      regionEndpoint?: string(name='RegionEndpoint', description='The endpoint of the Tag service in the region.', example='tag.aliyuncs.com'),
      regionId?: string(name='RegionId', description='The ID of the region.', example='cn-hangzhou'),
    }
  ](name='Region')
  }(name='Regions', description='The information of the regions.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='632BBAE2-9C44-4212-8B51-B54742DA9713'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @summary Queries the regions where the Tag service is available.
 *
 * @param request DescribeRegionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the regions where the Tag service is available.
 *
 * @param request DescribeRegionsRequest
 * @return DescribeRegionsResponse
 */
async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DetachPolicyRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-a3381efe2fe34a75****'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  targetId?: string(name='TargetId', description='The ID of the object.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required.', example='151266687691****'),
  targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required. The value of this parameter is not case-sensitive.', example='ACCOUNT'),
}

model DetachPolicyResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='4A32F5B0-0B0B-5537-B4A0-7A6E1C3AA96A'),
}

model DetachPolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DetachPolicyResponseBody(name='body'),
}

/**
 * @summary 解除策略绑定
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to detach a tag policy from the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to detach a tag policy from the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to detach the tag policy with an ID of `p-a3381efe2fe34a75****` from the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request DetachPolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DetachPolicyResponse
 */
async function detachPolicyWithOptions(request: DetachPolicyRequest, runtime: Util.RuntimeOptions): DetachPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DetachPolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 解除策略绑定
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to detach a tag policy from the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to detach a tag policy from the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to detach the tag policy with an ID of `p-a3381efe2fe34a75****` from the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request DetachPolicyRequest
 * @return DetachPolicyResponse
 */
async function detachPolicy(request: DetachPolicyRequest): DetachPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return detachPolicyWithOptions(request, runtime);
}

model DisablePolicyTypeRequest {
  openType?: string(name='OpenType'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
  userType?: string(name='UserType'),
}

model DisablePolicyTypeResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='6E27F22C-EDA3-132E-A53F-77DE3BC2343D'),
}

model DisablePolicyTypeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisablePolicyTypeResponseBody(name='body'),
}

/**
 * @summary 关闭策略
 *
 * @param request DisablePolicyTypeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisablePolicyTypeResponse
 */
async function disablePolicyTypeWithOptions(request: DisablePolicyTypeRequest, runtime: Util.RuntimeOptions): DisablePolicyTypeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.openType)) {
    query['OpenType'] = request.openType;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DisablePolicyType',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 关闭策略
 *
 * @param request DisablePolicyTypeRequest
 * @return DisablePolicyTypeResponse
 */
async function disablePolicyType(request: DisablePolicyTypeRequest): DisablePolicyTypeResponse {
  var runtime = new Util.RuntimeOptions{};
  return disablePolicyTypeWithOptions(request, runtime);
}

model EnablePolicyTypeRequest {
  openType?: string(name='OpenType'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
  userType?: string(name='UserType'),
}

model EnablePolicyTypeResponseBody = {
  requestId?: string(name='RequestId', example='6E27F22C-EDA3-132E-A53F-77DE3BC2343D'),
}

model EnablePolicyTypeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnablePolicyTypeResponseBody(name='body'),
}

/**
 * @summary 开通策略
 *
 * @param request EnablePolicyTypeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnablePolicyTypeResponse
 */
async function enablePolicyTypeWithOptions(request: EnablePolicyTypeRequest, runtime: Util.RuntimeOptions): EnablePolicyTypeResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.openType)) {
    query['OpenType'] = request.openType;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'EnablePolicyType',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 开通策略
 *
 * @param request EnablePolicyTypeRequest
 * @return EnablePolicyTypeResponse
 */
async function enablePolicyType(request: EnablePolicyTypeRequest): EnablePolicyTypeResponse {
  var runtime = new Util.RuntimeOptions{};
  return enablePolicyTypeWithOptions(request, runtime);
}

model GenerateConfigRuleReportRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  targetId?: string(name='TargetId', description='The ID of the object.', example='154950938137****'),
  targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  The value of this parameter is not case-sensitive.', example='ACCOUNT'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).

>  This parameter is required if the management account of your resource directory is used to enable the Tag Policy feature in both single-account mode and multi-account mode. The value of this parameter is not case-sensitive.', example='USER'),
}

model GenerateConfigRuleReportResponseBody = {
  reportId?: string(name='ReportId', description='The ID of the resource non-compliance report.', example='crp-ao0786618088006c****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='37B2AC06-89D8-5D95-98DF-3E68C12BDE05'),
}

model GenerateConfigRuleReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GenerateConfigRuleReportResponseBody(name='body'),
}

/**
 * @summary 生成规则检测报告
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to generate a resource non-compliance report for the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to generate a resource non-compliance report for the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call this API operation to generate a resource non-compliance report for the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request GenerateConfigRuleReportRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GenerateConfigRuleReportResponse
 */
async function generateConfigRuleReportWithOptions(request: GenerateConfigRuleReportRequest, runtime: Util.RuntimeOptions): GenerateConfigRuleReportResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GenerateConfigRuleReport',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 生成规则检测报告
 *
 * @description If you use the Tag Policy feature in single-account mode, you can call this API operation to generate a resource non-compliance report for the current logon account. If you use the Tag Policy feature in multi-account mode, you can call this API operation to generate a resource non-compliance report for the Root folder, a folder other than the Root folder, or a member in a resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call this API operation to generate a resource non-compliance report for the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request GenerateConfigRuleReportRequest
 * @return GenerateConfigRuleReportResponse
 */
async function generateConfigRuleReport(request: GenerateConfigRuleReportRequest): GenerateConfigRuleReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateConfigRuleReportWithOptions(request, runtime);
}

model GetConfigRuleReportRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  targetId?: string(name='TargetId', description='The ID of the object.', example='154950938137****'),
  targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  The value of this parameter is not case-sensitive.', example='USER'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).

>  The value of this parameter is not case-sensitive.', example='USER'),
}

model GetConfigRuleReportResponseBody = {
  data?: {
    createdTime?: long(name='CreatedTime', description='The time when the report was generated. This value is a UNIX timestamp.', example='1655089159000'),
    reportId?: string(name='ReportId', description='The ID of the report.', example='crp-ao0786618088006c****'),
    targetId?: string(name='TargetId', description='The ID of the object.

>  This parameter is returned if you set the `TargetType` and `TargetId` parameters in the current request to the same values as the parameters that are configured when you call the [GenerateConfigRuleReport](https://help.aliyun.com/document_detail/433313.html) operation to generate the report.', example='154950938137****'),
    targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  This parameter is returned if you set the `TargetType` and `TargetId` parameters in the current request to the same values as the parameters that are configured when you call the [GenerateConfigRuleReport](https://help.aliyun.com/document_detail/433313.html) operation to generate the report.', example='ACCOUNT'),
  }(name='Data', description='The basic information of the resource non-compliance report that is last generated.'),
  httpStatusCode?: int32(name='HttpStatusCode', description='The HTTP status code.', example='200'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='A68BD5BC-5B12-5A9B-8AE9-77884886BE10'),
  success?: boolean(name='Success', description='Indicates whether the request is successful. Valid values:

*   true: The request is successful.
*   false: The request fails.', example='true'),
}

model GetConfigRuleReportResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetConfigRuleReportResponseBody(name='body'),
}

/**
 * @summary Queries the basic information of the resource non-compliance report that is last generated.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the basic information of the resource non-compliance report that is last generated for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the basic information of the resource non-compliance report that is last generated for an object in the resource directory. The object can be the Root folder, a folder other than the Root folder, or a member. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call this API operation to query the basic information of the resource non-compliance report that is last generated for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that the ID of the report is `crp-ao0786618088006c****`.
 *
 * @param request GetConfigRuleReportRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetConfigRuleReportResponse
 */
async function getConfigRuleReportWithOptions(request: GetConfigRuleReportRequest, runtime: Util.RuntimeOptions): GetConfigRuleReportResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetConfigRuleReport',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the basic information of the resource non-compliance report that is last generated.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the basic information of the resource non-compliance report that is last generated for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the basic information of the resource non-compliance report that is last generated for an object in the resource directory. The object can be the Root folder, a folder other than the Root folder, or a member. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call this API operation to query the basic information of the resource non-compliance report that is last generated for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that the ID of the report is `crp-ao0786618088006c****`.
 *
 * @param request GetConfigRuleReportRequest
 * @return GetConfigRuleReportResponse
 */
async function getConfigRuleReport(request: GetConfigRuleReportRequest): GetConfigRuleReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return getConfigRuleReportWithOptions(request, runtime);
}

model GetEffectivePolicyRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tagKeys?: [ string ](name='TagKeys'),
  targetId?: string(name='TargetId', description='The ID of the object.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required.', example='154950938137****'),
  targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  If you use the Tag Policy feature in single-account mode, this parameter is optional. If you use the Tag Policy feature in multi-account mode, this feature is required. The value of this parameter is not case-sensitive.', example='ACCOUNT'),
}

model GetEffectivePolicyResponseBody = {
  effectivePolicy?: string(name='EffectivePolicy', description='The effective tag policy.', example='{\\\\"tags\\\\":{\\\\"costcenter\\\\":{\\\\"tag_value\\\\":[\\\\"Beijing\\\\",\\\\"Shanghai\\\\"],\\\\"tag_key\\\\":\\\\"CostCenter\\\\"}}}'),
  policyAttachments?: [ 
    {
      policyList?: [ 
        {
          attachSeq?: int32(name='AttachSeq'),
          attachTime?: string(name='AttachTime'),
          policyId?: string(name='PolicyId'),
          policyName?: string(name='PolicyName'),
          targetId?: string(name='TargetId'),
          targetType?: string(name='TargetType'),
        }
      ](name='PolicyList'),
      policyType?: string(name='PolicyType'),
      tagKey?: string(name='TagKey'),
    }
  ](name='PolicyAttachments'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='BB532282-94F5-5F56-877F-32D5E2A04F3F'),
}

model GetEffectivePolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetEffectivePolicyResponseBody(name='body'),
}

/**
 * @summary 查询有效策略
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the effective tag policy for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the effective tag policy for the Root folder, a folder other than the Root folder, or a member in the resource directory. You can also use a member of a resource directory to call this API operation to query the effective tag policy for the member. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * An effective tag policy is obtained based on tag policy inheritance. For more information, see [Inheritance of a tag policy and calculation of an effective tag policy](https://help.aliyun.com/document_detail/417435.html).
 * This topic provides an example on how to call the API operation to query the effective tag policy for the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request GetEffectivePolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetEffectivePolicyResponse
 */
async function getEffectivePolicyWithOptions(request: GetEffectivePolicyRequest, runtime: Util.RuntimeOptions): GetEffectivePolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tagKeys)) {
    query['TagKeys'] = request.tagKeys;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetEffectivePolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询有效策略
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the effective tag policy for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the effective tag policy for the Root folder, a folder other than the Root folder, or a member in the resource directory. You can also use a member of a resource directory to call this API operation to query the effective tag policy for the member. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * An effective tag policy is obtained based on tag policy inheritance. For more information, see [Inheritance of a tag policy and calculation of an effective tag policy](https://help.aliyun.com/document_detail/417435.html).
 * This topic provides an example on how to call the API operation to query the effective tag policy for the current logon account. In this example, the Tag Policy feature in single-account mode is used.
 *
 * @param request GetEffectivePolicyRequest
 * @return GetEffectivePolicyResponse
 */
async function getEffectivePolicy(request: GetEffectivePolicyRequest): GetEffectivePolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return getEffectivePolicyWithOptions(request, runtime);
}

model GetPolicyRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-557cb141331f41c7****'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
}

model GetPolicyResponseBody = {
  policy?: {
    policyContent?: string(name='PolicyContent', description='The document of the tag policy.', example='{\\\\"tags\\\\":{\\\\"CostCenter\\\\":{\\\\"tag_value\\\\":{\\\\"@@assign\\\\":[\\\\"Beijing\\\\",\\\\"Shanghai\\\\"]},\\\\"tag_key\\\\":{\\\\"@@assign\\\\":\\\\"CostCenter\\\\"}}}}'),
    policyDesc?: string(name='PolicyDesc', description='The description of the tag policy.', example='This is a tag policy example.'),
    policyName?: string(name='PolicyName', description='The name of the tag policy.', example='test'),
    userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).', example='USER'),
  }(name='Policy', description='The details of the tag policy.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='1E7A4802-AB57-570A-9860-F15B60E1586B'),
}

model GetPolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPolicyResponseBody(name='body'),
}

/**
 * @summary 查询策略
 *
 * @description This topic provides an example on how to call the API operation to query the details of the tag policy with an ID of `p-557cb141331f41c7****`.
 *
 * @param request GetPolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPolicyResponse
 */
async function getPolicyWithOptions(request: GetPolicyRequest, runtime: Util.RuntimeOptions): GetPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询策略
 *
 * @description This topic provides an example on how to call the API operation to query the details of the tag policy with an ID of `p-557cb141331f41c7****`.
 *
 * @param request GetPolicyRequest
 * @return GetPolicyResponse
 */
async function getPolicy(request: GetPolicyRequest): GetPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPolicyWithOptions(request, runtime);
}

model GetPolicyEnableStatusRequest {
  openType?: string(name='OpenType', description='The enabling type. Valid values:

*   TAG_POLICY: the Tag Policy feature.
*   VERIFY_NO_TAG: the strong verification feature.', example='TAG_POLICY'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. This parameter specifies a filter condition for the query. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).

>  The value of this parameter is not case-sensitive.', example='RD'),
}

model GetPolicyEnableStatusResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='6C8DF1B1-C65F-5D3A-9FDA-26A4683BB36B'),
  statusModels?: [ 
    {
      status?: string(name='Status', description='The status of the Tag Policy feature. Valid values:

*   PendingEnable: The feature is being enabled.
*   Enabled: The feature is enabled.
*   Closing: The feature is being disabled.
*   Disabled: The feature is disabled.', example='Enabled'),
      userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).', example='RD'),
    }
  ](name='StatusModels', description='The information of the Tag Policy feature.'),
}

model GetPolicyEnableStatusResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPolicyEnableStatusResponseBody(name='body'),
}

/**
 * @summary Queries the status of the Tag Policy feature.
 *
 * @description This topic provides an example on how to call the API operation to query the status of the Tag Policy feature for the current logon account. The response shows that the Tag Policy feature in multi-account mode is enabled for the current logon account.
 *
 * @param request GetPolicyEnableStatusRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPolicyEnableStatusResponse
 */
async function getPolicyEnableStatusWithOptions(request: GetPolicyEnableStatusRequest, runtime: Util.RuntimeOptions): GetPolicyEnableStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.openType)) {
    query['OpenType'] = request.openType;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPolicyEnableStatus',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the status of the Tag Policy feature.
 *
 * @description This topic provides an example on how to call the API operation to query the status of the Tag Policy feature for the current logon account. The response shows that the Tag Policy feature in multi-account mode is enabled for the current logon account.
 *
 * @param request GetPolicyEnableStatusRequest
 * @return GetPolicyEnableStatusResponse
 */
async function getPolicyEnableStatus(request: GetPolicyEnableStatusRequest): GetPolicyEnableStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPolicyEnableStatusWithOptions(request, runtime);
}

model ListAssociatedResourceRulesRequest {
  maxResult?: int32(name='MaxResult', example='50'),
  nextToken?: string(name='NextToken', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  settingName?: [ string ](name='SettingName'),
  status?: string(name='Status', example='Enable'),
}

model ListAssociatedResourceRulesResponseBody = {
  nextToken?: string(name='NextToken', description='This parameter is required.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', example='6E27F22C-EDA3-132E-A53F-77DE3BC2343D'),
  rules?: [ 
    {
      settingName?: string(name='SettingName', example='rule:UpdateLoadBalancerZones-UpdateLoadBalancerAddressTypeConfig-TagAlb:Alb-LoadBalancer:Vpc-Eip'),
      status?: string(name='Status', example='Disable/Enable'),
      tagKeys?: [ string ](name='TagKeys'),
    }
  ](name='Rules'),
}

model ListAssociatedResourceRulesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListAssociatedResourceRulesResponseBody(name='body'),
}

/**
 * @summary 用户已设置的关联资源打TAG规则
 *
 * @param request ListAssociatedResourceRulesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListAssociatedResourceRulesResponse
 */
async function listAssociatedResourceRulesWithOptions(request: ListAssociatedResourceRulesRequest, runtime: Util.RuntimeOptions): ListAssociatedResourceRulesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.settingName)) {
    query['SettingName'] = request.settingName;
  }
  if (!Util.isUnset(request.status)) {
    query['Status'] = request.status;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListAssociatedResourceRules',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 用户已设置的关联资源打TAG规则
 *
 * @param request ListAssociatedResourceRulesRequest
 * @return ListAssociatedResourceRulesResponse
 */
async function listAssociatedResourceRules(request: ListAssociatedResourceRulesRequest): ListAssociatedResourceRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listAssociatedResourceRulesWithOptions(request, runtime);
}

model ListConfigRulesForTargetRequest {
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Default value: 50. Maximum value: 1000.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyType?: string(name='PolicyType', description='The use scenario of the tag policy. This parameter specifies a filter condition for the query. Valid values:

*   tags: enables tags with specified tag values to be added to resources.
*   rg_inherit: enables resources in a resource group to automatically inherit tags from the resource group.', example='tags'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tagKey?: string(name='TagKey', description='The tag key. This parameter specifies a filter condition for the query.', example='CostCenter'),
  targetId?: string(name='TargetId', description='The ID of the object. This parameter specifies a filter condition for the query.', example='134254031178****'),
  targetType?: string(name='TargetType', description='The type of the object. This parameter specifies a filter condition for the query. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  The value of this parameter is not case-sensitive.', example='ACCOUNT'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. This parameter specifies a filter condition for the query. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).

>  The value of this parameter is not case-sensitive.', example='USER'),
}

model ListConfigRulesForTargetResponseBody = {
  data?: [ 
    {
      aggregatorId?: string(name='AggregatorId', description='The ID of the account group.

You can use the ID to query the content of the related resource non-compliance report in Cloud Config.

>  This parameter is returned only if you use the Tag Policy feature in multi-account mode.', example='ca-efdc33dc9b37002d****'),
      configRuleId?: string(name='ConfigRuleId', description='The ID of the rule.', example='cr-0lb4866180880069****'),
      policyType?: string(name='PolicyType', description='The use scenario of the tag policy. Valid values:

*   tags: enables tags with specified tag values to be added to resources.
*   rg_inherit: enables resources in a resource group to automatically inherit tags from the resource group.', example='tags'),
      remediation?: boolean(name='Remediation', description='Indicates whether automatic remediation is enabled. Valid values:

*   true
*   false', example='false'),
      tagKey?: string(name='TagKey', description='The tag key.', example='CostCenter'),
      tagValue?: string(name='TagValue', description='The tag value for automatic remediation.', example='Project'),
      targetId?: string(name='TargetId', description='The ID of the object.', example='134254031178****'),
      targetType?: string(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.', example='USER'),
    }
  ](name='Data', description='The tag detection tasks.'),
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='7126AECD-D7AD-5073-8E88-DD2BD1FC139E'),
}

model ListConfigRulesForTargetResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListConfigRulesForTargetResponseBody(name='body'),
}

/**
 * @summary Queries a list of tag detection tasks for an object.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the tag detection tasks for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the tag detection tasks for the Root folder, a folder other than the Root folder, or a member in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the tag detection tasks for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that only one tag detection task exists.
 *
 * @param request ListConfigRulesForTargetRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListConfigRulesForTargetResponse
 */
async function listConfigRulesForTargetWithOptions(request: ListConfigRulesForTargetRequest, runtime: Util.RuntimeOptions): ListConfigRulesForTargetResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyType)) {
    query['PolicyType'] = request.policyType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tagKey)) {
    query['TagKey'] = request.tagKey;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListConfigRulesForTarget',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries a list of tag detection tasks for an object.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the tag detection tasks for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the tag detection tasks for the Root folder, a folder other than the Root folder, or a member in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the tag detection tasks for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that only one tag detection task exists.
 *
 * @param request ListConfigRulesForTargetRequest
 * @return ListConfigRulesForTargetResponse
 */
async function listConfigRulesForTarget(request: ListConfigRulesForTargetRequest): ListConfigRulesForTargetResponse {
  var runtime = new Util.RuntimeOptions{};
  return listConfigRulesForTargetWithOptions(request, runtime);
}

model ListPoliciesRequest {
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Default value: 50. Maximum value: 1000.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyIds?: [ string ](name='PolicyIds', description='The ID of a tag policy. This parameter specifies a filter condition for the query.'),
  policyNames?: [ string ](name='PolicyNames', description='The name of a tag policy. This parameter specifies a filter condition for the query.'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  userType?: string(name='UserType', description='The mode of the Tag Policy feature. This parameter specifies a filter condition for the query. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).

>  The value of this parameter is not case-sensitive.', example='USER'),
}

model ListPoliciesResponseBody = {
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  policyList?: [ 
    {
      policyContent?: string(name='PolicyContent', description='The document of the tag policy.', example='{\\\\"tags\\\\":{\\\\"CostCenter\\\\":{\\\\"tag_value\\\\":{\\\\"@@assign\\\\":[\\\\"Beijing\\\\",\\\\"Shanghai\\\\"]},\\\\"tag_key\\\\":{\\\\"@@assign\\\\":\\\\"CostCenter\\\\"}}}}'),
      policyDesc?: string(name='PolicyDesc', description='The description of the tag policy.', example='This is a tag policy example.'),
      policyId?: string(name='PolicyId', description='The ID of the tag policy.', example='p-de62a0bf400e4b69****'),
      policyName?: string(name='PolicyName', description='The name of the tag policy.', example='example'),
      userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).', example='USER'),
    }
  ](name='PolicyList', description='The tag policies.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='72477CFF-5B24-5E30-9861-3DD9C4BD46E5'),
}

model ListPoliciesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListPoliciesResponseBody(name='body'),
}

/**
 * @summary Queries tag policies.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query all tag policies that are created for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query all tag policies that are created for the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query all tag policies that are created for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that two tag policies are created.
 *
 * @param request ListPoliciesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListPoliciesResponse
 */
async function listPoliciesWithOptions(request: ListPoliciesRequest, runtime: Util.RuntimeOptions): ListPoliciesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyIds)) {
    query['PolicyIds'] = request.policyIds;
  }
  if (!Util.isUnset(request.policyNames)) {
    query['PolicyNames'] = request.policyNames;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.userType)) {
    query['UserType'] = request.userType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPolicies',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries tag policies.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query all tag policies that are created for the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query all tag policies that are created for the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query all tag policies that are created for the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that two tag policies are created.
 *
 * @param request ListPoliciesRequest
 * @return ListPoliciesResponse
 */
async function listPolicies(request: ListPoliciesRequest): ListPoliciesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPoliciesWithOptions(request, runtime);
}

model ListPoliciesForTargetRequest {
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Default value: 50. Maximum value: 1000.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  targetId?: string(name='TargetId', description='The ID of the object. This parameter specifies a filter condition for the query.', example='154950938137****'),
  targetType?: string(name='TargetType', description='The type of the object. This parameter specifies a filter condition for the query. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in a resource directory. This value is available if you use the Tag Policy feature in multi-account mode.

>  The value of this parameter is not case-sensitive.', example='ACCOUNT'),
}

model ListPoliciesForTargetResponseBody = {
  data?: [ 
    {
      policyContent?: string(name='PolicyContent', description='The document of the tag policy.', example='{\\\\"tags\\\\":{\\\\"CostCenter\\\\":{\\\\"tag_value\\\\":{\\\\"@@assign\\\\":[\\\\"Beijing\\\\",\\\\"Shanghai\\\\"]},\\\\"tag_key\\\\":{\\\\"@@assign\\\\":\\\\"CostCenter\\\\"}}}}'),
      policyDesc?: string(name='PolicyDesc', description='The description of the tag policy.', example='This is a tag policy example.'),
      policyId?: string(name='PolicyId', description='The ID of the tag policy.', example='p-de62a0bf400e4b69****'),
      policyName?: string(name='PolicyName', description='The name of the tag policy.', example='example'),
      userType?: string(name='UserType', description='The mode of the Tag Policy feature. Valid values:

*   USER: single-account mode
*   RD: multi-account mode

For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).', example='USER'),
    }
  ](name='Data', description='The tag policies that are attached to the object.'),
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='8C962146-AB38-516C-818C-695D4E9F2EA2'),
}

model ListPoliciesForTargetResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListPoliciesForTargetResponseBody(name='body'),
}

/**
 * @summary Queries the tag policies that are attached to an object.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the tag policies that are attached to the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the tag policies that are attached to the Root folder, a folder other than the Root folder, or a member in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the tag policies that are attached to the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that only one tag policy is attached to the current logon account.
 *
 * @param request ListPoliciesForTargetRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListPoliciesForTargetResponse
 */
async function listPoliciesForTargetWithOptions(request: ListPoliciesForTargetRequest, runtime: Util.RuntimeOptions): ListPoliciesForTargetResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.targetId)) {
    query['TargetId'] = request.targetId;
  }
  if (!Util.isUnset(request.targetType)) {
    query['TargetType'] = request.targetType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPoliciesForTarget',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the tag policies that are attached to an object.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the tag policies that are attached to the account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the tag policies that are attached to the Root folder, a folder other than the Root folder, or a member in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the tag policies that are attached to the current logon account. In this example, the Tag Policy feature in single-account mode is used. The response shows that only one tag policy is attached to the current logon account.
 *
 * @param request ListPoliciesForTargetRequest
 * @return ListPoliciesForTargetResponse
 */
async function listPoliciesForTarget(request: ListPoliciesForTargetRequest): ListPoliciesForTargetResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPoliciesForTargetWithOptions(request, runtime);
}

model ListResourcesByTagRequest {
  tagFilter?: {
    key?: string(name='Key', description='The tag key. This parameter specifies a filter condition for the query.

The tag key can be a maximum of 128 characters in length. It cannot contain `http://` or `https://` and cannot start with `acs:` or `aliyun`.

This parameter is required.', example='k1'),
    value?: string(name='Value', description='The tag value. This parameter specifies a filter condition for the query.

The tag value can be up to 128 characters in length and cannot contain `http://` or `https://`.', example='v1'),
  }(name='TagFilter'),
  fuzzyType?: string(name='FuzzyType', description='The type of the query. Valid values:

*   EQUAL: exact match for resources to which the specified tag is added. This is the default value.
*   NOT: exact match for resources to which the specified tag is not added.', example='EQUAL'),
  includeAllTags?: boolean(name='IncludeAllTags', description='Specifies whether to return the information of tags added to the resources. Valid values:

*   False: does not return the information of tags added to the resources. This is the default value.
*   True: returns the information of all tags added to the resources.', example='False'),
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Default value: 50. Maximum value: 1000.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID.

For more information about region IDs, see [Endpoints](https://help.aliyun.com/document_detail/2330902.html).

This parameter is required.', example='cn-shenzhen'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceType?: string(name='ResourceType', description='The resource type. This parameter specifies a filter condition for the query.

*   If you set the FuzzyType parameter to EQUAL, you can set this parameter to a value obtained from the response of the [ListSupportResourceTypes](https://help.aliyun.com/document_detail/2330915.html) operation.
*   If you set the FuzzyType parameter to NOT, you can set this parameter to a resource type provided in **Types of resources that support queries based on the NOT operator**.

This parameter is required.', example='ALIYUN::VPC::VPC'),
}

model ListResourcesByTagResponseBody = {
  nextToken?: string(name='NextToken', description='Indicates whether the `next query` is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the `next query` is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the `token` used to start the next query.

This parameter is required.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='7D61FF74-61C2-5768-B01F-05FC97F24F35'),
  resources?: [ 
    {
      resourceId?: string(name='ResourceId', description='The ID of the resource.', example='vpc-wz9pifyuw26esxd05****'),
      tags?: [ 
        {
          category?: string(name='Category', description='The type of the tag. Valid values:

*   custom
*   system', example='custom'),
          key?: string(name='Key', description='The tag key.', example='k1'),
          value?: string(name='Value', description='The tag value.', example='v1'),
        }
      ](name='Tags', description='The information of the tags.

This parameter is returned only if the `IncludeAllTags` parameter is set to `True`.'),
    }
  ](name='Resources', description='The information of the resources.'),
}

model ListResourcesByTagResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourcesByTagResponseBody(name='body'),
}

/**
 * @summary Queries resources to which a specified tag is added or resources to which a specified tag is not added.
 *
 * @description This topic provides an example on how to call the API operation in the China (Shenzhen) region to query virtual private clouds (VPCs) to which the tag key `k1` is added. The response shows that the tag key is added to two VPCs.
 *
 * @param request ListResourcesByTagRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourcesByTagResponse
 */
async function listResourcesByTagWithOptions(request: ListResourcesByTagRequest, runtime: Util.RuntimeOptions): ListResourcesByTagResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.fuzzyType)) {
    query['FuzzyType'] = request.fuzzyType;
  }
  if (!Util.isUnset(request.includeAllTags)) {
    query['IncludeAllTags'] = request.includeAllTags;
  }
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tagFilter)) {
    query['TagFilter'] = request.tagFilter;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourcesByTag',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries resources to which a specified tag is added or resources to which a specified tag is not added.
 *
 * @description This topic provides an example on how to call the API operation in the China (Shenzhen) region to query virtual private clouds (VPCs) to which the tag key `k1` is added. The response shows that the tag key is added to two VPCs.
 *
 * @param request ListResourcesByTagRequest
 * @return ListResourcesByTagResponse
 */
async function listResourcesByTag(request: ListResourcesByTagRequest): ListResourcesByTagResponse {
  var runtime = new Util.RuntimeOptions{};
  return listResourcesByTagWithOptions(request, runtime);
}

model ListSupportResourceTypesRequest {
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Maximum value: 1000. Default value: 50.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='AAAAAYws9fJ0Ur4MGm/5OkDoW/Y3wDNwUdssyKODK****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  productCode?: string(name='ProductCode', description='The service code. This parameter specifies a filter condition for the query.

This parameter is obtained from the response.', example='ecs'),
  regionId?: string(name='RegionId', description='The region ID.

For more information about region IDs, see [Endpoints](https://help.aliyun.com/document_detail/2330902.html).', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceTye?: string(name='ResourceTye', description='The resource type. This parameter specifies a filter condition for the query.

This parameter is obtained from the response.', example='instance'),
  showItems?: boolean(name='ShowItems', description='Specifies whether to return tag-related capability items. Valid values:

*   true: The system returns tag-related capability items.
*   false (default value): The system does not return tag-related capability items.', example='false'),
  supportCode?: string(name='SupportCode', description='The code of the tag-related capability item. This parameter specifies a filter condition for the query.

For more information, see **Tag-related capability items**.', example='TAG_CONSOLE_SUPPORT'),
}

model ListSupportResourceTypesResponseBody = {
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required.

*   If the value of this parameter is empty, all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='AAAAAYws9fJ0Ur4MGm****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='ABC71772-F3A1-59CA-B811-4A5B0E0B72F8'),
  supportResourceTypes?: [ 
    {
      arnTemplate?: string(name='ArnTemplate', description='The resource ARN template.', example='acs:ecs:*:*:instance/${ResourceId}'),
      productCode?: string(name='ProductCode', description='The service code.', example='ecs'),
      resourceType?: string(name='ResourceType', description='The resource type.', example='instance'),
      supportItems?: [ 
        {
          support?: boolean(name='Support', description='Indicates whether the tag-related capability item is supported. Valid values:

*   true
*   false', example='true'),
          supportCode?: string(name='SupportCode', description='The code of the tag-related capability item.', example='TAG_CONSOLE_SUPPORT'),
          supportDetails?: [ map[string]string ](name='SupportDetails', description='The details of the support for the tag-related capability item.'),
        }
      ](name='SupportItems', description='The supported tag-related capability items.

>  This parameter is returned only if the `ShowItems` parameter is set to `true`.'),
    }
  ](name='SupportResourceTypes', description='The supported resource types.'),
}

model ListSupportResourceTypesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSupportResourceTypesResponseBody(name='body'),
}

/**
 * @summary Queries the resource types supported by tags and tag-related capability items.
 *
 * @description ### [](#)Call example
 * *   Query a list of resource types supported by TagResources or UntagResources. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22,%22SupportCode%22:%22TAG_CONSOLE_SUPPORT%22%7D).
 * *   Query a list of resource types supported by ListTagResources or ListResourcesByTag. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22%7D).
 * *   Query a list of resource types that support createdby tags. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22,%22SupportCode%22:%22CREATED_BY_TAG_CONSOLE_SUPPORT%22%7D).
 *
 * @param request ListSupportResourceTypesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSupportResourceTypesResponse
 */
async function listSupportResourceTypesWithOptions(request: ListSupportResourceTypesRequest, runtime: Util.RuntimeOptions): ListSupportResourceTypesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceTye)) {
    query['ResourceTye'] = request.resourceTye;
  }
  if (!Util.isUnset(request.showItems)) {
    query['ShowItems'] = request.showItems;
  }
  if (!Util.isUnset(request.supportCode)) {
    query['SupportCode'] = request.supportCode;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSupportResourceTypes',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the resource types supported by tags and tag-related capability items.
 *
 * @description ### [](#)Call example
 * *   Query a list of resource types supported by TagResources or UntagResources. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22,%22SupportCode%22:%22TAG_CONSOLE_SUPPORT%22%7D).
 * *   Query a list of resource types supported by ListTagResources or ListResourcesByTag. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22%7D).
 * *   Query a list of resource types that support createdby tags. For more information, see [Example](https://api.alibabacloud.com/api/Tag/2018-08-28/ListSupportResourceTypes?tab=DEBUG\\&params=%7B%22RegionId%22:%22cn-hangzhou%22,%22SupportCode%22:%22CREATED_BY_TAG_CONSOLE_SUPPORT%22%7D).
 *
 * @param request ListSupportResourceTypesRequest
 * @return ListSupportResourceTypesResponse
 */
async function listSupportResourceTypes(request: ListSupportResourceTypesRequest): ListSupportResourceTypesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSupportResourceTypesWithOptions(request, runtime);
}

model ListTagKeysRequest {
  tagFilter?: {
    key?: string(name='Key', description='The tag key for a fuzzy query.

This parameter is used together with the `FuzzyType` parameter.', example='team'),
  }(name='TagFilter'),
  category?: string(name='Category', description='The type of the resource tags. This parameter specifies a filter condition for the query. Valid values:

*   all (default value)
*   custom
*   system

>  The value of this parameter is not case-sensitive.', example='all'),
  fuzzyType?: string(name='FuzzyType', description='The type of the query. Valid values:

*   EQUAL (default): exact match
*   PREFIX: prefix-based fuzzy match', example='EQUAL'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  pageSize?: int32(name='PageSize', description='The number of tag keys to return on each page.

Maximum value: 1000. Default value: 50.', example='50'),
  queryType?: string(name='QueryType', description='The category of the tags. This parameter specifies a filter condition for the query. Valid values:

*   ResourceTag: resource tags, including custom and system tags. This is the default value.
*   MetaTag: preset tags.

>  The value of this parameter is not case-sensitive.', example='ResourceTag'),
  regionId?: string(name='RegionId', description='The region ID.

For more information about region IDs, see [Endpoints](https://help.aliyun.com/document_detail/2330902.html).

This parameter is required.', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceType?: string(name='ResourceType', description='The resource type. This parameter specifies a filter condition for the query.

Format: `ALIYUN::${ProductCode}::${ResourceType}`. All letters in the value of this parameter must be in uppercase.

*   `ProductCode`: the service code. You can set this field to a value obtained from the response of the [ListSupportResourceTypes](https://help.aliyun.com/document_detail/2330915.html) operation.
*   `ResourceType`: the resource type. You can set this field to a value obtained from the response of the [ListSupportResourceTypes](https://help.aliyun.com/document_detail/2330915.html) operation.', example='ALIYUN::ECS::INSTANCE'),
}

model ListTagKeysResponseBody = {
  keys?: {
    key?: [ 
    {
      category?: string(name='Category', description='The type of the resource tag. Valid values:

*   custom
*   system', example='custom'),
      description?: string(name='Description', description='The description of the tag key.', example='Business team'),
      key?: string(name='Key', description='The tag key.', example='team'),
    }
  ](name='Key')
  }(name='Keys', description='The information of the tag keys.'),
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required. The value of this parameter may be empty.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='DC09A6AA-2713-4E10-A2E9-E6C5C43A8842'),
}

model ListTagKeysResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTagKeysResponseBody(name='body'),
}

/**
 * @summary Queries tag keys.
 *
 * @description This topic provides an example on how to call the API operation to query the tag keys in the `cn-hangzhou` region. The response shows that the following tag keys exist: `team`, `k1`, and `k2`.
 *
 * @param request ListTagKeysRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTagKeysResponse
 */
async function listTagKeysWithOptions(request: ListTagKeysRequest, runtime: Util.RuntimeOptions): ListTagKeysResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.category)) {
    query['Category'] = request.category;
  }
  if (!Util.isUnset(request.fuzzyType)) {
    query['FuzzyType'] = request.fuzzyType;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queryType)) {
    query['QueryType'] = request.queryType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tagFilter)) {
    query['TagFilter'] = request.tagFilter;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagKeys',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries tag keys.
 *
 * @description This topic provides an example on how to call the API operation to query the tag keys in the `cn-hangzhou` region. The response shows that the following tag keys exist: `team`, `k1`, and `k2`.
 *
 * @param request ListTagKeysRequest
 * @return ListTagKeysResponse
 */
async function listTagKeys(request: ListTagKeysRequest): ListTagKeysResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagKeysWithOptions(request, runtime);
}

model ListTagResourcesRequest {
  category?: string(name='Category', description='The type of the tag. Valid values:

*   Custom
*   System
*   All

Default value: All.', example='Custom'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  pageSize?: int32(name='PageSize', description='The number of entries to return on each page.

Maximum value: 1000. Default value: 50.', example='50'),
  regionId?: string(name='RegionId', description='The region ID.

*   If the resources belong to a service that is centrally deployed, set the value to the region ID of the resources by referring to [Regions supported by tag-related operations on resources of centrally deployed Alibaba Cloud services](https://help.aliyun.com/document_detail/2579691.html).
*   If the resources belong to a service that is not centrally deployed, set the value to the region ID of the resources.

This parameter is required.', example='cn-hangzhou'),
  resourceARN?: [ string ](name='ResourceARN', description='The Alibaba Cloud Resource Name (ARN) of a resource.', example='arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg****'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tags?: string(name='Tags', description='The key-value pairs of tags. You can specify 1 to 10 key-value pairs.

If you specify multiple tags, the system queries the resources to which all these tags are added.

Limits:

*   A tag key must be 1 to 128 characters in length.
*   A tag value must be 1 to 128 characters in length.
*   Tag keys and tag values are case-sensitive.
*   Each tag key on a resource can have only one tag value. If you create a tag that has the same key as an existing tag, the value of the existing tag is overwritten.', example='{"k1":"v1","k2":"v2"}'),
}

model ListTagResourcesResponseBody = {
  nextToken?: string(name='NextToken', description='Indicates whether the `next query` is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the `next query` is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the `token` used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='014738E0-3C7F-47D8-8FB9-469500C6F387'),
  tagResources?: [ 
    {
      resourceARN?: string(name='ResourceARN', description='The ARN of the resource.', example='arn:acs:ecs:cn-hangzhou:123456789****:instance/i-bp15hr53jws84akg****'),
      tags?: [ 
        {
          category?: string(name='Category', description='The type of the tag. Valid values:

*   Custom
*   System', example='Custom'),
          key?: string(name='Key', description='The tag key.', example='k1'),
          value?: string(name='Value', description='The tag value.', example='v1'),
        }
      ](name='Tags', description='The information of the tags.'),
    }
  ](name='TagResources', description='The information of the tags that are added to the resources.'),
}

model ListTagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTagResourcesResponseBody(name='body'),
}

/**
 * @summary Queries the tags that are added to the resources of various Alibaba Cloud services.
 *
 * @description For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request ListTagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTagResourcesResponse
 */
async function listTagResourcesWithOptions(request: ListTagResourcesRequest, runtime: Util.RuntimeOptions): ListTagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.category)) {
    query['Category'] = request.category;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceARN)) {
    query['ResourceARN'] = request.resourceARN;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tags)) {
    query['Tags'] = request.tags;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagResources',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the tags that are added to the resources of various Alibaba Cloud services.
 *
 * @description For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request ListTagResourcesRequest
 * @return ListTagResourcesResponse
 */
async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagResourcesWithOptions(request, runtime);
}

model ListTagValuesRequest {
  tagFilter?: {
    value?: string(name='Value', description='The tag value for a fuzzy query.

This parameter is used together with the `FuzzyType` parameter.', example='v1'),
  }(name='TagFilter'),
  fuzzyType?: string(name='FuzzyType', description='The type of the query. Valid values:

*   EQUAL (default): exact match
*   PREFIX: prefix-based fuzzy match', example='EQUAL'),
  key?: string(name='Key', description='The tag key. This parameter specifies a filter condition for the query.

This parameter is required.', example='k1'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  pageSize?: int32(name='PageSize', description='The number of tag values to return on each page.

Maximum value: 1000. Default value: 50.', example='50'),
  queryType?: string(name='QueryType', description='The category of the tags. This parameter specifies a filter condition for the query. Valid values:

*   ResourceTag: resource tags, including custom and system tags. This is the default value.
*   MetaTag: preset tags.

>  The value of this parameter is not case-sensitive.', example='ResourceTag'),
  regionId?: string(name='RegionId', description='The region ID.

For more information about region IDs, see [Endpoints](https://help.aliyun.com/document_detail/2330902.html).

This parameter is required.', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceType?: string(name='ResourceType', description='The resource type. This parameter specifies a filter condition for the query.

Format: `ALIYUN::${ProductCode}::${ResourceType}`. All letters in the value of this parameter must be in uppercase.

*   `ProductCode`: the service code. You can set this field to a value obtained from the response of the [ListSupportResourceTypes](https://help.aliyun.com/document_detail/2330915.html) operation.
*   `ResourceType`: the resource type. You can set this field to a value obtained from the response of the [ListSupportResourceTypes](https://help.aliyun.com/document_detail/2330915.html) operation.', example='ALIYUN::ECS::INSTANCE'),
}

model ListTagValuesResponseBody = {
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required. The value of this parameter may be empty.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='8989CA7E-D2E0-4B6D-8282-311106E80150'),
  values?: {
    value?: [ string ](name='Value')
  }(name='Values', description='The information of the tag values.'),
}

model ListTagValuesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTagValuesResponseBody(name='body'),
}

/**
 * @summary Queries the tag values of a tag key.
 *
 * @description This topic provides an example on how to call the API operation to query the values of the tag key `k1` in the `cn-hangzhou` region. The response shows that the value of the tag key `k1` is `v1`.
 *
 * @param request ListTagValuesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTagValuesResponse
 */
async function listTagValuesWithOptions(request: ListTagValuesRequest, runtime: Util.RuntimeOptions): ListTagValuesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.fuzzyType)) {
    query['FuzzyType'] = request.fuzzyType;
  }
  if (!Util.isUnset(request.key)) {
    query['Key'] = request.key;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.queryType)) {
    query['QueryType'] = request.queryType;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.tagFilter)) {
    query['TagFilter'] = request.tagFilter;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTagValues',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the tag values of a tag key.
 *
 * @description This topic provides an example on how to call the API operation to query the values of the tag key `k1` in the `cn-hangzhou` region. The response shows that the value of the tag key `k1` is `v1`.
 *
 * @param request ListTagValuesRequest
 * @return ListTagValuesResponse
 */
async function listTagValues(request: ListTagValuesRequest): ListTagValuesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagValuesWithOptions(request, runtime);
}

model ListTargetsForPolicyRequest {
  maxResult?: int32(name='MaxResult', description='The number of entries to return on each page.

Default value: 50. Maximum value: 1000.', example='50'),
  nextToken?: string(name='NextToken', description='The token that is used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-de62a0bf400e4b69****'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
}

model ListTargetsForPolicyResponseBody = {
  isRd?: boolean(name='IsRd', description='Indicates whether the object belongs to the resource directory. Valid values:

*   true: The object belongs to the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   false: The object does not belong to the resource directory. This value is available if you use the Tag Policy feature in single-account mode.', example='true'),
  nextToken?: string(name='NextToken', description='Indicates whether the next query is required.

*   If the value of this parameter is empty (`"NextToken": ""`), all results are returned, and the next query is not required.
*   If the value of this parameter is not empty, the next query is required, and the value is the token used to start the next query.', example='caeba0bbb2be03f84eb48b699f0a****'),
  rdId?: string(name='RdId', description='The ID of the resource directory.

>  This parameter is returned only if you use the Tag Policy feature in multi-account mode.', example='rd-3G****'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='2EE71C8D-6DB8-56AC-8B05-3D4C0116E6A1'),
  targets?: [ 
    {
      targetId?: string(name='TargetId', description='The ID of the object.', example='195320939469****'),
      targetType?: int32(name='TargetType', description='The type of the object. Valid values:

*   USER: the current logon account. This value is available if you use the Tag Policy feature in single-account mode.
*   ROOT: the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   FOLDER: a folder other than the Root folder in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.
*   ACCOUNT: a member in the resource directory. This value is available if you use the Tag Policy feature in multi-account mode.', example='ACCOUNT'),
    }
  ](name='Targets', description='The objects to which the tag policy is attached.'),
}

model ListTargetsForPolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTargetsForPolicyResponseBody(name='body'),
}

/**
 * @summary Queries the objects to which a tag policy is attached.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the object to which a tag policy is attached. The object is the current logon account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the objects to which a tag policy is attached. The objects include the Root folder, folders other than the Root folder, and members in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the objects to which the tag policy with an ID of `p-de62a0bf400e4b69****` is attached. In this example, the Tag Policy feature in multi-account mode is used. The response shows that the tag policy is attached to two members in the related resource directory.
 *
 * @param request ListTargetsForPolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTargetsForPolicyResponse
 */
async function listTargetsForPolicyWithOptions(request: ListTargetsForPolicyRequest, runtime: Util.RuntimeOptions): ListTargetsForPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.maxResult)) {
    query['MaxResult'] = request.maxResult;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListTargetsForPolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the objects to which a tag policy is attached.
 *
 * @description If you use the Tag Policy feature in single-account mode, you can use the current logon account to call this API operation to query the object to which a tag policy is attached. The object is the current logon account. If you use the Tag Policy feature in multi-account mode, you can use the management account of a resource directory to call this API operation to query the objects to which a tag policy is attached. The objects include the Root folder, folders other than the Root folder, and members in the resource directory. For more information about the modes of the Tag Policy feature, see [Modes of the Tag Policy feature](https://help.aliyun.com/document_detail/417434.html).
 * This topic provides an example on how to call the API operation to query the objects to which the tag policy with an ID of `p-de62a0bf400e4b69****` is attached. In this example, the Tag Policy feature in multi-account mode is used. The response shows that the tag policy is attached to two members in the related resource directory.
 *
 * @param request ListTargetsForPolicyRequest
 * @return ListTargetsForPolicyResponse
 */
async function listTargetsForPolicy(request: ListTargetsForPolicyRequest): ListTargetsForPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTargetsForPolicyWithOptions(request, runtime);
}

model ModifyPolicyRequest {
  dryRun?: boolean(name='DryRun', description='Specifies whether to perform a dry run for the request. Valid values:

*   false: The system performs the related operation based on the parameter settings in the request. This is the default value.
*   true: The system does not perform the related operation based on the parameter settings in the request but only verifies the parameter settings.', example='false'),
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  policyContent?: string(name='PolicyContent', description='The document of the tag policy.

For more information about the syntax of a tag policy, see [Syntax of a tag policy](https://help.aliyun.com/document_detail/417436.html).', example='{"tags":{"CostCenter":{"tag_value":{"@@assign":["Beijing","Shanghai"]},"tag_key":{"@@assign":"CostCenter"}}}}', nullable=true),
  policyDesc?: string(name='PolicyDesc', description='The description of the tag policy.

The description must be 0 to 512 characters in length.', example='This is a tag policy example.', nullable=true),
  policyId?: string(name='PolicyId', description='The ID of the tag policy.

This parameter is required.', example='p-5732750813924f90****'),
  policyName?: string(name='PolicyName', description='The name of the tag policy.

The name must be 1 to 128 characters in length and can contain letters, digits, and underscores (_).', example='test', nullable=true),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
}

model ModifyPolicyResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='4A32F5B0-0B0B-5537-B4A0-7A6E1C3AA96A'),
}

model ModifyPolicyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyPolicyResponseBody(name='body'),
}

/**
 * @summary 修改策略
 *
 * @description This topic provides an example on how to call the API operation to change the name of a tag policy to `test`.
 *
 * @param request ModifyPolicyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ModifyPolicyResponse
 */
async function modifyPolicyWithOptions(request: ModifyPolicyRequest, runtime: Util.RuntimeOptions): ModifyPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dryRun)) {
    query['DryRun'] = request.dryRun;
  }
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.policyContent)) {
    query['PolicyContent'] = request.policyContent;
  }
  if (!Util.isUnset(request.policyDesc)) {
    query['PolicyDesc'] = request.policyDesc;
  }
  if (!Util.isUnset(request.policyId)) {
    query['PolicyId'] = request.policyId;
  }
  if (!Util.isUnset(request.policyName)) {
    query['PolicyName'] = request.policyName;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyPolicy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 修改策略
 *
 * @description This topic provides an example on how to call the API operation to change the name of a tag policy to `test`.
 *
 * @param request ModifyPolicyRequest
 * @return ModifyPolicyResponse
 */
async function modifyPolicy(request: ModifyPolicyRequest): ModifyPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyPolicyWithOptions(request, runtime);
}

model OpenCreatedByRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID. Set the value to cn-shanghai.

This parameter is required.', example='cn-shanghai'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: string(name='ResourceOwnerId'),
}

model OpenCreatedByResponseBody = {
  requestId?: string(name='RequestId', description='The ID of the request.', example='74F03511-FDFA-54AF-96A4-71575B41E74D'),
}

model OpenCreatedByResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: OpenCreatedByResponseBody(name='body'),
}

/**
 * @summary Enables createdby tags.
 *
 * @description createdby tags can help you analyze costs and bills and manage the costs of cloud resources in an efficient manner. You can identify the creators of resources based on the createdby tags added to the resources. createdby tags are system tags that are provided by Alibaba Cloud and automatically added to resources. The key of createdby tags is `acs:tag:createdby`.
 *
 * @param request OpenCreatedByRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return OpenCreatedByResponse
 */
async function openCreatedByWithOptions(request: OpenCreatedByRequest, runtime: Util.RuntimeOptions): OpenCreatedByResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'OpenCreatedBy',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Enables createdby tags.
 *
 * @description createdby tags can help you analyze costs and bills and manage the costs of cloud resources in an efficient manner. You can identify the creators of resources based on the createdby tags added to the resources. createdby tags are system tags that are provided by Alibaba Cloud and automatically added to resources. The key of createdby tags is `acs:tag:createdby`.
 *
 * @param request OpenCreatedByRequest
 * @return OpenCreatedByResponse
 */
async function openCreatedBy(request: OpenCreatedByRequest): OpenCreatedByResponse {
  var runtime = new Util.RuntimeOptions{};
  return openCreatedByWithOptions(request, runtime);
}

model TagResourcesRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID.

*   If the resources belong to a service that is centrally deployed, set the value to `cn-hangzhou` or to the region ID of the resources by referring to [Regions supported by tag-related operations on resources of centrally deployed Alibaba Cloud services](https://help.aliyun.com/document_detail/2579691.html).
*   If the resources belong to a service that is not centrally deployed, set the value to the region ID of the resources.

This parameter is required.', example='cn-hangzhou'),
  resourceARN?: [ string ](name='ResourceARN', description='The Alibaba Cloud Resource Name (ARN) of a resource.

This parameter is required.', example='arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tags?: string(name='Tags', description='The key-value pairs of tags. You can specify 1 to 10 key-value pairs.

If you specify multiple tags, the system adds all the tags to the specified resources.

Limits:

*   A tag key must be 1 to 128 characters in length.
*   A tag value must be 1 to 128 characters in length.
*   Tag keys and tag values are case-sensitive.
*   Each tag key on a resource can have only one tag value. If you create a tag that has the same key as an existing tag, the value of the existing tag is overwritten.

This parameter is required.', example='{"k1":"v1","k2":"v2"}'),
}

model TagResourcesResponseBody = {
  failedResources?: {
    failedResource?: [ 
    {
      resourceARN?: string(name='ResourceARN', description='The ARN of the resource.', example='arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****'),
      result?: {
        code?: string(name='Code', description='The error code.', example='InvalidResourceId.NotFound'),
        message?: string(name='Message', description='The error message.', example='The specified ResourceIds are not found in our records.'),
      }(name='Result', description='The information about the error.'),
    }
  ](name='FailedResource')
  }(name='FailedResources', description='The information about the resources to which tags fail to be added.

> 

*   If tags are added to all resources, the value of `FailedResources` is empty.

*   If tags fail to be added to some or all resources, the value of `FailedResources` contains the detailed information about the resources.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='72086426-9F8C-4A60-852B-864048FD1199'),
}

model TagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TagResourcesResponseBody(name='body'),
}

/**
 * @summary Adds tags to the resources of various Alibaba Cloud services.
 *
 * @description Tags are used to identify resources. Tags allow you to categorize, search for, and aggregate resources that have the same characteristics from different dimensions. This facilitates resource management. For more information, see [Tag overview](https://help.aliyun.com/document_detail/156983.html).
 * For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request TagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return TagResourcesResponse
 */
async function tagResourcesWithOptions(request: TagResourcesRequest, runtime: Util.RuntimeOptions): TagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceARN)) {
    query['ResourceARN'] = request.resourceARN;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tags)) {
    query['Tags'] = request.tags;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TagResources',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Adds tags to the resources of various Alibaba Cloud services.
 *
 * @description Tags are used to identify resources. Tags allow you to categorize, search for, and aggregate resources that have the same characteristics from different dimensions. This facilitates resource management. For more information, see [Tag overview](https://help.aliyun.com/document_detail/156983.html).
 * For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request TagResourcesRequest
 * @return TagResourcesResponse
 */
async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return tagResourcesWithOptions(request, runtime);
}

model UntagResourcesRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', description='The region ID.

*   If the resources belong to a service that is centrally deployed, set the value to `cn-hangzhou` or to the region ID of the resources by referring to [Regions supported by tag-related operations on resources of centrally deployed Alibaba Cloud services](https://help.aliyun.com/document_detail/2579691.html).
*   If the resources belong to a service that is not centrally deployed, set the value to the region ID of the resources.

This parameter is required.', example='cn-hangzhou'),
  resourceARN?: [ string ](name='ResourceARN', description='The Alibaba Cloud Resource Name (ARN) of a resource.

This parameter is required.', example='arn:acs:vpc:cn-hangzhou:123456789****:vpc/vpc-bp19dd90tkt6tz7wu****'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  tagKey?: [ string ](name='TagKey', description='The key of tag N.

Valid values of N: 1 to 10.

This parameter is required.', example='k1'),
}

model UntagResourcesResponseBody = {
  failedResources?: {
    failedResource?: [ 
    {
      resourceARN?: string(name='ResourceARN', description='The ARN of the resource.', example='arn:acs:ecs:cn-hangzhou:123456789****:instance/i-xxxxxxxxxx1'),
      result?: {
        code?: string(name='Code', description='The error code.', example='InvalidResourceId.NotFound'),
        message?: string(name='Message', description='The error message.', example='The specified ResourceIds are not found in our records.'),
      }(name='Result', description='The information about the error.'),
    }
  ](name='FailedResource')
  }(name='FailedResources', description='The information about the resources from which tags fail to be removed.

> 

*   If tags are removed from all resources, the value of FailedResources is empty.

*   If tags fail to be removed from some or all resources, the value of FailedResources contains the detailed information about the resources.'),
  requestId?: string(name='RequestId', description='The ID of the request.', example='43D12436-B10F-4469-8136-FD1C5D2B2083'),
}

model UntagResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UntagResourcesResponseBody(name='body'),
}

/**
 * @summary Removes tags from the resources of various Alibaba Cloud services.
 *
 * @description After you remove a tag, the tag is automatically deleted within 24 hours if it is not added to other resources.
 * For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request UntagResourcesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UntagResourcesResponse
 */
async function untagResourcesWithOptions(request: UntagResourcesRequest, runtime: Util.RuntimeOptions): UntagResourcesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceARN)) {
    query['ResourceARN'] = request.resourceARN;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.tagKey)) {
    query['TagKey'] = request.tagKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UntagResources',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Removes tags from the resources of various Alibaba Cloud services.
 *
 * @description After you remove a tag, the tag is automatically deleted within 24 hours if it is not added to other resources.
 * For information about the Alibaba Cloud services that support tags, see [Services that work with Tag](https://help.aliyun.com/document_detail/171455.html).
 *
 * @param request UntagResourcesRequest
 * @return UntagResourcesResponse
 */
async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return untagResourcesWithOptions(request, runtime);
}

model UpdateAssociatedResourceRuleRequest {
  ownerAccount?: string(name='OwnerAccount'),
  ownerId?: long(name='OwnerId'),
  regionId?: string(name='RegionId', example='cn-hangzhou'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  settingName?: string(name='SettingName', description='This parameter is required.', example='rule:AssociateEip-UnassociateEip-TagInstance:Ecs-Instance:Vpc-Eip'),
  status?: string(name='Status', example='Enable'),
  tagKeys?: [ string ](name='TagKeys'),
}

model UpdateAssociatedResourceRuleResponseBody = {
  requestId?: string(name='RequestId', example='94E16BB6-3FB6-1297-B5B2-ED2250F437CD'),
}

model UpdateAssociatedResourceRuleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateAssociatedResourceRuleResponseBody(name='body'),
}

/**
 * @summary 更新关联资源打TAG规则
 *
 * @param request UpdateAssociatedResourceRuleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateAssociatedResourceRuleResponse
 */
async function updateAssociatedResourceRuleWithOptions(request: UpdateAssociatedResourceRuleRequest, runtime: Util.RuntimeOptions): UpdateAssociatedResourceRuleResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.ownerAccount)) {
    query['OwnerAccount'] = request.ownerAccount;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.regionId)) {
    query['RegionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.settingName)) {
    query['SettingName'] = request.settingName;
  }
  if (!Util.isUnset(request.status)) {
    query['Status'] = request.status;
  }
  if (!Util.isUnset(request.tagKeys)) {
    query['TagKeys'] = request.tagKeys;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateAssociatedResourceRule',
    version = '2018-08-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 更新关联资源打TAG规则
 *
 * @param request UpdateAssociatedResourceRuleRequest
 * @return UpdateAssociatedResourceRuleResponse
 */
async function updateAssociatedResourceRule(request: UpdateAssociatedResourceRuleRequest): UpdateAssociatedResourceRuleResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateAssociatedResourceRuleWithOptions(request, runtime);
}

